package com.suineg.pms.web.base;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.suineg.pms.entity.base.Company;
import com.suineg.pms.service.base.CompanyServcie;

/**
 * 
 *@author Suine
 */
@Controller
@RequestMapping(value = "/base/company")
public class CompanyController {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	private CompanyServcie companyServcie;
	
	@RequestMapping(value = "checkName")
	@ResponseBody
	public String checkCompanyNane(@RequestParam("name") String companNane){
		if(companNane == null || companNane.isEmpty()){
			return "false";
		}
		Company company = companyServcie.findByName(companNane);
		if(company == null){
			return "true";
		}else{
			return "false";
		}
	}

	@Autowired
	public void setCompanyServcie(CompanyServcie companyServcie) {
		this.companyServcie = companyServcie;
	}
	
	@RequestMapping(value = "")
	public String excute(){
		return "base/company";
	}
}

